//
//  ZOrderMallWebVC.m
//  DistributorAB
//
//  Created by LZY on 2019/10/21.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "ZOrderMallWebVC.h"
#import "BBuyNowShopDetailVC.h"//产品详情界面

@interface ZOrderMallWebVC ()

@end

@implementation ZOrderMallWebVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupNavViewAction];
    
    self.webView.frame = CGRectMake(0, -kDHeight, kScreen_Width, kScreen_Height + kDHeight);
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}
#pragma mark - 自定义导航栏
- (void)setupNavViewAction{
    UIButton *btnBack = [UIButton buttonWithType:UIButtonTypeCustom];
    btnBack.frame = CGRectMake(8, kDHeight + 5, 34, 34);
    [btnBack setImage:imgname(@"arrow_left_white_icon") forState:UIControlStateNormal];
    [btnBack addTarget:self action:@selector(btnBackClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btnBack];
}
#pragma mark - 交互事件
- (void)btnBackClickAction:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message{
    
    //JS调用OC
    NSDictionary *dict = message.body;
    if ([message.name isEqualToString:@"jsCallOCYMD"]) {
        if ([HFTools isDictionary:dict]) {
            NSLog(@"立即抢购%@",dict);
            BBuyNowShopDetailVC *vc = [[BBuyNowShopDetailVC alloc] init];
            vc.shopID = [dict objectForKeyNotNil:@"params"];
            [self.navigationController pushViewController:vc animated:YES];
        }
        
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
